function Nnext_Nxz = gen_law_of_motion_N(parms,gesol)

    NN = parms.NN;
    Nx = parms.Nx;
    Nz = parms.Nz;
    
    % dynamics for N' = N'(N,lambda,z)
    survive_Nxz = permute(repmat(1 - parms.s(:),[1 NN Nx]),[2 3 1]);
    N_Nxz = repmat(parms.grid_N(:),[1 Nx Nz]);
    Nnext_Nxz = zeros(NN,Nx,Nz); % N'=N'(N,L,z)
    Nnext_Nxz(:,:,:) = survive_Nxz.*N_Nxz + gesol.f.*(1-N_Nxz);
    Nnext_Nxz(Nnext_Nxz<parms.grid_N(1)) = parms.grid_N(1);
    Nnext_Nxz(Nnext_Nxz>parms.grid_N(end)) = parms.grid_N(end);

end